package com.web.security.filter;

import com.web.security.token.FrontAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xf
 * Date: 2016/4/21
 * Time: 20:34
 * To change this template use Editor | File and Code Templates.
 */
public class FrontAuthenticationTokenResolver extends AbstractAuthenticationTokenResolver {

    public FrontAuthenticationTokenResolver() {
        super();
    }

    @Override
    public Authentication resolve(HttpServletRequest request) {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String validateCode = request.getParameter("validateCode");
        List<GrantedAuthority> authorities = new ArrayList<>();
        return new FrontAuthenticationToken(username, password, validateCode, authorities);
    }


}
